<?php
namespace app\admin\model;
use think\Model;

class OrderPartDeliveryApplyItem extends BaseModel
{
    // 定义数据表名
    protected $name = 'order_part_delivery_apply_item';

    // 定义主键
    protected $primaryKey = 'id';

    // 定义创建时间字段名
    protected $createTime = 'create_time';

    // 定义自动时间戳
    protected $autoWriteTimestamp = true;

    // 设置字段信息
    protected $schema = [
        'id'                           => 'int',
        'order_part_delivery_apply_id' => 'int',
        'order_item_id'               => 'int',
        'warehouse_id'                => 'int',
        'product_id'                  => 'int',
        'is_futures'                  => 'int',
        'arrival_date'                => 'date',
        'real_arrival_date'           => 'date',
        'apply_quantity'              => 'int',
        'pending_quantity'                    => 'int',
        'creator'                     => 'int',
        'create_time'                 => 'datetime',
        'is_del'                      => 'int'
    ];

    /**
     * 关联主表
     */
    public function apply()
    {
        return $this->belongsTo(OrderPartDeliveryApply::class, 'order_part_delivery_apply_id', 'id');
    }

    /**
     * 关联订单项
     */
    public function orderItem()
    {
        return $this->belongsTo(OrderItem::class, 'order_item_id', 'id');
    }
}
